package businessdelegate;

import java.util.List;
import java.util.Properties;

import javax.ejb.Local;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import entitiesdto.ArticuloDTO;
import entitiesdto.CantidadMateriaPrimaDTO;
import entitiesdto.MateriaPrimaDTO;
import entitiesdto.SolicitudFabricacionDTO;
import facade.SessionFacade;

@Local
public class FacadeBusinessDelegate implements SessionFacade {

	private SessionFacade sessionFacade;
	private InitialContext ic;
	private static FacadeBusinessDelegate INSTANCE;

	public FacadeBusinessDelegate() throws NamingException {
		Properties props = new Properties();
		props.put(InitialContext.INITIAL_CONTEXT_FACTORY,
				"org.jnp.interfaces.NamingContextFactory");
		props.put(InitialContext.PROVIDER_URL, "jnp://localhost:1099");
		ic = new InitialContext(props);
		System.out.println(sessionFacade);
		sessionFacade = (SessionFacade) ic
				.lookup("fabrica-zara-EAR/SessionFacadeBean/remote");
		System.out.println(sessionFacade);
	}

	public static FacadeBusinessDelegate getInstance() throws NamingException {
		if (INSTANCE == null) {
			INSTANCE = new FacadeBusinessDelegate();
		}
		return INSTANCE;
	}

	public String getTexto(int numero) {
		return sessionFacade.getTexto(numero);
	}
	
	public boolean ingresarNuevoArticulo(ArticuloDTO art) {
		return sessionFacade.ingresarNuevoArticulo(art);
	}

	public boolean crearPedidoFabricacion() {
		return false;
	}

	public boolean generarReposicionArticulos() {
		return sessionFacade.generarReposicionArticulos();
	}

	public List<MateriaPrimaDTO> getMateriasPrimas() {
		return null;
	}

	public boolean modificarPedidoFabricacion() {
		return false;
	}

	public List<CantidadMateriaPrimaDTO> recibirProvedores(List<CantidadMateriaPrimaDTO> actualizacionStock) {
		return sessionFacade.recibirProvedores(actualizacionStock);
	}

	public boolean recibirSolicitudFabricacion(SolicitudFabricacionDTO sol) {
		return false;
	}

	public boolean verificarPedidosExistentes() {
		return false;
	}

}
